/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 *
 * $Id: WirelessClient.hpp,v 1.4 2009-05-13 07:18:19 amaula Exp $
 *
 * \file
 * \brief MaCI - Wireless Interface Client header
 * \author Antti Maula <antti.maula@tkk.fi>
 */
#ifndef _MACI_INTERFACE_WIRELESSCLIENT_HPP_
#define _MACI_INTERFACE_WIRELESSCLIENT_HPP_

#include "MaCI.hpp"
//#include "thread.hpp"
//#include "sync.hpp"

// These are not necessarily required here, but defined to make the
// interface easier to include.
#include "WirelessData.hpp"

// Forward declare gimi::GIMI
namespace gimi {
  class GIMI;
}

namespace MaCI {
  namespace Wireless {
    
    // Forward declaration.
    class CWirelessData;


    /** MaCI - Wireless Client interface.
     * 
     * This class contains the methods and types for using
     * a MaCI::Wireless service in the GIMnet.
     */
    class CWirelessClient 
      : //private gim::CSync,
        //private gim::CThread,
        public MaCI::CMaCI
    {
    public:
      /** Constructor.
       * 
       * Constructor of the WirelessClient. This requires;
       * a pointer to Initialized and connected GIMI, minor
       * number of this interface (Used as GIMI minor number)
       *
       * @param[in] aGIMIPtr Pointer to GIMI used for communication
       * @param[in] aInterfaceMinor Interface minor number. Usually
       *            used to indicate the instance of devices of same
       *            type. Can be left out if MaCISL is used.
       */     
      CWirelessClient(gimi::GIMI *aGIMIPtr, const int aInterfaceMinor = -1);

      
      /** Destructor.
       */
      ~CWirelessClient();


      /** Receive WirelessEvent.
       *
       */
      bool WaitWirelessEvent(CWirelessData &aData, 
                             const unsigned int aTimeout_ms);
      

      /** Send Wireless Command.
       *
       */
      bool SendCommand(CWirelessData &aCmd);
      
      
    protected:
      /** Open client interface.
       */
      EMaCIError DoOpen(void);
      
      
      /** Close client interface.
       */
      EMaCIError DoClose(void);


    private:
      /// Thread runner function. Is in charge of receiving events.
      //     int ThreadFunction(const int aThreadNumber);
      //     int ProcessMessage(const gimi::GIMIMessage &msg);

      //data.
      unsigned int iWirelessSequence;
      CWirelessData iLastWirelessData;
    };


  }
}

#endif //_MACI_INTERFACE_WIRELESSCLIENT_HPP_
